// comcontent/switch/switch.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    onesrc:'http://icon.tongchengyouzhi.com/jigouxiangqin/jigoujianjie.png',
    onedes:'机构简介',
    twosrc:'http://icon.tongchengyouzhi.com/jigouxiangqin/zhaoping.png',
    twodes:'招聘',
    threesrc:'http://icon.tongchengyouzhi.com/jigouxiangqin/pingtuan.png',
    threedes:'拼团',
    foursrc:'http://icon.tongchengyouzhi.com/jigouxiangqin/jinpingkecheng.png',
    fourdes:'精品课程',
    id:1,
    line1:"border-bottom: 4rpx #02a0e9 solid",
    line2:"",
    line3:"",
    line4: "",
    color1:"#02a0e9",
    color2:"#535353",
    color3:"#535353",
    color4: "#535353"
  },

  /**
   * 组件的方法列表
   */
  methods: {
   xuanze:function(e)
   { 
     var that=this;
     var id
   
     var x = e.detail.x;
     if(x<100)
     { 
       id=1
       that.setData({
         line1:'border-bottom: 4rpx #02a0e9 solid',
         line2: "",
         line3: "",
         line4: "",
         color1: "#02a0e9",
         color2: "#535353",
         color3: "#535353",
         color4: "#535353"
         
       })
     }else if(x>100&&x<200)
     {
       id = 2
       that.setData({
         line1: '',
         line2: "border-bottom: 4rpx #02a0e9 solid",
         line3: "",
         line4: "",
         color1: "#535353",
         color2: "#02a0e9",
         color3: "#535353",
         color4: "#535353"
       
       })
     } else if (x > 200 && x < 300)
     {
       id = 3
       that.setData({
         line1: '',
         line2: "",
         line3: "border-bottom: 4rpx #02a0e9 solid",
         line4: "",
         color1: "#535353",
         color2: "#535353",
         color3: "#02a0e9",
         color4: "#535353"
       })
     }else{
       id = 4
       that.setData({
         line1: '',
         line2: "",
         line3: "",
         line4: "border-bottom: 4rpx #02a0e9 solid",
         color1: "#535353",
         color2: "#535353",
         color3: "#535353",
         color4: "#02a0e9"
         
        
       })
     }
     
     this.triggerEvent('switch',{id},{})
   }
  }
})
